package com.ytf.core.web.pojo.converter;

import com.ytf.core.web.pojo.dto.RoleDto;
import com.ytf.core.web.pojo.model.Role;
import com.ytf.core.web.pojo.vo.RoleVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author YTF
 * @className RoleConverter
 * @date 2025/5/21 16:25
 * @description 角色实体类转换器
 */
@Mapper(componentModel = "spring")
public interface RoleConverter {

    RoleConverter INSTANCE = Mappers.getMapper(RoleConverter.class);

    @Mapping(target = "id", ignore = true)  // DTO转Entity时忽略id
    @Mapping(target = "createTime", ignore = true) // 创建时间由数据库自动生成
    Role roleDtoToRole(RoleDto dto);

    RoleVo roleToRoleVo(Role Role);
}
